//
//  LBDouyinCell.m
//  TEXT
//
//  Created by mac on 2024/7/7.
//  Copyright © 2024 刘博. All rights reserved.
//

#import "LBDouyinCell.h"

@interface LBDouyinCell () <UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *commentTableView;

@property (nonatomic, strong) UILabel *titleLabel;

@end

@implementation LBDouyinCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUpUI];
    }
    return self;
}

- (void)setUpUI
{
    [self.contentView addSubview:self.commentTableView];
    [self.contentView addSubview:self.titleLabel];
    [self.commentTableView reloadData];
}

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
   // self.parentTableView.scrollEnabled = NO;
    NSLog(@"阿哈哈哈内层的内层的scrollViewWillBeginDragging");;
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    NSLog(@"哈哈哈哈哈内层的内层的scrollViewDidScroll");
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
   // self.parentTableView.scrollEnabled = YES;
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
    if (!decelerate) {
        //self.parentTableView.scrollEnabled = YES;
    }
}

#pragma mark - UITableViewDelegate, UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 60;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([UITableViewCell class])];
    cell.textLabel.text = [NSString stringWithFormat:@"哈哈哈这里是第%ld条", indexPath.row];
    return cell;
}

- (void)updateWithTitle:(NSString *)title
{
    self.titleLabel.text= title;
}

#pragma mark - lazy load

- (UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, 200, 50)];
        _titleLabel.backgroundColor = [UIColor magentaColor];
        _titleLabel.text = @"我是标题";
    }
    return _titleLabel;
}

- (UITableView *)commentTableView
{
    if (!_commentTableView) {
        _commentTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 400, 200, 200) style:UITableViewStylePlain];
        _commentTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        [_commentTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:NSStringFromClass([UITableViewCell class])];
        _commentTableView.delegate = self;
        _commentTableView.dataSource = self;
    }
    return _commentTableView;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
